home *** CD-ROM | disk | FTP | other *** search
/ Animation / Animation Vol.1 (Profi ROM)(1994).iso / pool / updates / symantec / rtlinc.exe / STDIO.H < prev    next >
C/C++ Source or Header  |  1993-08-02  |  8KB  |  271 lines

  1. /*_ stdio.h   Fri Nov 24 1989    Modified by: Walter Bright */
  2. /* Standard I/O header file    */
  3. /* $Revision:   1.2  $ */
  4.  
  5. #ifndef __STDIO_H
  6. #define __STDIO_H
  7.  
  8. #if __cplusplus
  9. extern "C" {
  10. #endif
  11.  
  12. #ifdef __STDC__
  13. #define __CDECL
  14. #define __STDCALL
  15. #else
  16. #define __CDECL __cdecl
  17. #define __STDCALL __stdcall
  18. #endif
  19.  
  20. #if __OS2__ && __INTSIZE == 4
  21. #define __CLIB    __STDCALL
  22. #else
  23. #define __CLIB    __CDECL
  24. #endif
  25.  
  26. #if M_UNIX || M_XENIX || __NT__
  27. #define _NFILE    60        /* # of files we can have open at once    */
  28. #else
  29. #define _NFILE    32        /* # of files we can have open at once    */
  30. #endif
  31. #define EOF (-1)
  32.  
  33. #define SEEK_SET    0    /* seek from start of file    */
  34. #define SEEK_CUR    1    /* relative to current position */
  35. #define SEEK_END    2    /* relative to end of file    */
  36.  
  37. #ifndef NULL
  38. #if __COMPACT__ || __LARGE__ || __VCM__
  39. #define NULL 0L
  40. #else
  41. #define NULL 0
  42. #endif
  43. #endif
  44.  
  45. /* I/O buffer size    */
  46. #if M_UNIX || M_XENIX
  47. #define BUFSIZ        4096
  48. extern char * __CDECL _bufendtab[];
  49. #elif __INTSIZE == 4
  50. #define BUFSIZ        0x4000
  51. #else
  52. #define BUFSIZ        1024
  53. #endif
  54.  
  55. #if __INTSIZE == 2 && (__SMALL__ || __MEDIUM__)
  56. #define BIGBUF        (20 * 1024)
  57. #endif
  58.  
  59. typedef unsigned size_t;
  60.  
  61. /**** structure for high level file I/O ********/
  62.  
  63. typedef struct _iobuf
  64. {
  65. #if M_UNIX || M_XENIX
  66.     int    _cnt;        /* number of characters left in buffer    */
  67.     char    *_ptr;        /* pointer to next character position    */
  68.     char    *_base;     /* pointer to start of buffer        */
  69.     char    _flag;        /* various info about this channel    */
  70.     char    _file;        /* file "handle"            */
  71. #define _bufsize(f) (_bufendtab[(f)->_file] - (f)->_base)
  72. #elif __OS2__ && __INTSIZE == 4
  73.     char    *_ptr;
  74.     int    _cnt;
  75.     char    *_base;
  76.     int    _flag;
  77.     int    _file;
  78.     int    _charbuf;
  79.     int    _bufsiz;
  80.     int    __tmpnum;
  81. #define _bufsize(f) ((f)->_bufsiz)
  82. #elif __NT__
  83.     char    *_ptr;
  84.     int    _cnt;
  85.     char    *_base;
  86.     int    _flag;
  87.     int    _file;
  88.     int    _charbuf;
  89.     int    _bufsiz;
  90.     int    __tmpnum;
  91. #define _bufsize(f) ((f)->_bufsiz)
  92. #else
  93.     char    *_ptr;        /* pointer to next character position    */
  94.     int    _cnt;        /* number of characters left in buffer    */
  95.     char    *_base;        /* pointer to start of buffer        */
  96.     int    _flag;        /* various info about this channel    */
  97.     int    _file;        /* file "handle"            */
  98.     unsigned _bufsiz;    /* size of buffer being used        */
  99. #ifdef    BIGBUF
  100.     int    _seg;        /* segment of buffer if _IOBIGBUF    */
  101. #endif
  102. #define _bufsize(f) ((f)->_bufsiz)
  103. #endif
  104. } FILE;
  105.  
  106. /* file stream flags (Borland Compatibility) */
  107. #define _F_RDWR 0x0003       /* Read/write flag       */
  108. #define _F_READ 0x0001      /* Read only              */
  109. #define _F_WRIT 0x0002      /* Write only              */
  110. #define _F_BUF  0x0004      /* Malloc'ed Buffer      */
  111. #define _F_LBUF 0x0008      /* line-buffered             */
  112. #define _F_ERR  0x0010      /* Error                 */
  113. #define _F_EOF  0x0020      /* EOF                      */
  114. #define _F_BIN  0x0040      /* Binary file              */
  115. #define _F_IN   0x0080      /* Data in                 */
  116. #define _F_OUT  0x0100      /* Data out              */
  117. #define _F_TERM 0x0200      /* Terminal 'file'       */
  118.  
  119.  
  120. extern    FILE __CDECL _iob[_NFILE];
  121.  
  122. #define _IOREAD        1    /* file is opened for read        */
  123. #define _IOWRT        2    /* file is opened for write        */
  124. #define _IONBF        4    /* file I/O is not buffered        */
  125. #define _IOMYBUF    8    /* buffer allocated by setvbuf()    */
  126. #define _IOEOF        0x10    /* end of file has occurred        */
  127. #define _IOERR        0x20    /* error has occurred            */
  128. #define _IOLBF        0x40    /* file is line buffered        */
  129. #define _IORW        0x80    /* file is opened for reading and writing */
  130. #define _IOFBF        0    /* file is fully buffered        */
  131. #define _IOAPP        0x200 /* has the file been opened for append */
  132. #if M_UNIX || M_XENIX
  133. #define _IOTRAN        0    /* I/O is never translated under UNIX    */
  134. #else
  135. #define _IOTRAN        0x100    /* I/O is translated (not binary)    */
  136. #ifdef    BIGBUF
  137. #define _IOBIGBUF    0x400    /* the buffer is outside the data segment */
  138. #endif
  139. #endif
  140.  
  141. #define stdin    (&_iob[0])
  142. #define stdout    (&_iob[1])
  143. #define stderr    (&_iob[2])
  144.  
  145. #if M_UNIX || M_XENIX
  146. #define FOPEN_MAX    60
  147. #define FILENAME_MAX    255
  148. #else
  149. #ifndef __STDC__
  150. #ifndef __NT__
  151. #define stdaux    (&_iob[3])
  152. #define stdprn    (&_iob[4])
  153. #endif
  154. #endif
  155. #define FOPEN_MAX    20
  156. #define FILENAME_MAX    (3+64+8+1+3)
  157. #endif
  158.  
  159. #define L_tmpnam    7
  160. #define TMP_MAX        32767
  161.  
  162. typedef long fpos_t;
  163.  
  164. char *    __CLIB tmpnam(char *);
  165. FILE *    __CLIB fopen(const char *,const char *);
  166. FILE *    __CLIB _fsopen(const char *,const char *,int );
  167. FILE *    __CLIB freopen(const char *,const char *,FILE *);
  168. int    __CLIB fseek(FILE *,long,int);
  169. long    __CLIB ftell(FILE *);
  170. char *    __CLIB fgets(char *,int,FILE *);
  171. int    __CLIB fgetc(FILE *);
  172. int    __CLIB fflush(FILE *);
  173. int    __CLIB fclose(FILE *);
  174. int    __CLIB fputs(const char *,FILE *);
  175. int    __CLIB getc(FILE *);
  176. int    __CLIB getchar(void);
  177. char *    __CLIB gets(char *);
  178. int    __CLIB fputc(int,FILE *);
  179. int    __CLIB putc(int,FILE *);
  180. int    __CLIB putchar(int);
  181. int    __CLIB puts(const char *);
  182. int    __CLIB ungetc(int,FILE *);
  183. size_t    __CLIB fread(void *,size_t,size_t,FILE *);
  184. size_t    __CLIB fwrite(const void *,size_t,size_t,FILE *);
  185. int    __CDECL printf(const char *,...);
  186. int    __CDECL fprintf(FILE *,const char *,...);
  187. int    __CLIB  vfprintf(FILE *,const char *,char *);
  188. int    __CLIB  vprintf(const char *,char *);
  189. int    __CDECL sprintf(char *,const char *,...);
  190. int    __CLIB  vsprintf(char *,const char *,char *);
  191. int    __CDECL scanf(const char *,...);
  192. int    __CDECL fscanf(FILE *,const char *,...);
  193. int    __CDECL sscanf(const char *,const char *,...);
  194. void    __CLIB setbuf(FILE *,char *);
  195. int    __CLIB setvbuf(FILE *,char *,int,size_t);
  196. int    __CLIB remove(const char *);
  197. int    __CLIB rename(const char *,const char *);
  198. void    __CLIB rewind(FILE *);
  199. void    __CLIB clearerr(FILE *);
  200. int    __CLIB feof(FILE *);
  201. int    __CLIB ferror(FILE *);
  202. void    __CLIB perror(const char *);
  203. int    __CLIB fgetpos(FILE *,fpos_t *);
  204. int    __CLIB fsetpos(FILE *,const fpos_t *);
  205. FILE *    __CLIB tmpfile(void);
  206.  
  207. int __CLIB getw(FILE *FHdl);
  208. #define _getw  getw
  209. int __CLIB putw(int Word, FILE *FilePtr);
  210. #define _putw putw
  211.  
  212. #if __cplusplus
  213. inline int __CLIB getchar()        { return getc(stdin);        }
  214. inline int __CLIB putchar(int c)    { return putc(c,stdout);    }
  215. inline int __CLIB getc(FILE *fp)    { return fgetc(fp);        }
  216. inline int __CLIB putc(int c,FILE *fp)    { return fputc(c,fp);        }
  217. inline int __CLIB ferror(FILE *fp)    { return fp->_flag&_IOERR;    }
  218. inline int __CLIB feof(FILE *fp)    { return fp->_flag&_IOEOF;    }
  219. inline void __CLIB clearerr(FILE *fp)    { fp->_flag &= ~(_IOERR|_IOEOF); }
  220. inline void __CLIB rewind(FILE *fp)    { fseek(fp,0L,SEEK_SET); fp->_flag&=~_IOERR; }
  221. #else
  222. #define getchar()    getc(stdin)
  223. #define putchar(c)  putc(c,stdout)
  224. #define fgetchar() fgetc(stdin)
  225. #define _fgetchar() fgetc(stdin)
  226. #define fputchar(c) { return(fputc(c,stdout)); }
  227. #define _fputchar(c) { return(fputc(c,stdout)); }
  228. #define putch(c)    putc((c),stdout)
  229. #define _putch(c)    putc((c),stdout)
  230. #define getc(fp)    fgetc(fp)
  231. #define putc(c,fp)    fputc((c),(fp))
  232. #define ferror(fp)    ((fp)->_flag&_IOERR)
  233. #define feof(fp)    ((fp)->_flag&_IOEOF)
  234. #define clearerr(fp)    ((void)((fp)->_flag&=~(_IOERR|_IOEOF)))
  235. #define rewind(fp)    ((void)(fseek(fp,0L,SEEK_SET),((fp)->_flag&=~_IOERR)))
  236. #endif
  237.               
  238. #ifndef __STDC__    /* non-ANSI functions    */
  239. #define fileno(fp)    ((fp)->_file)
  240. #define _fileno(fp) ((fp)->_file)
  241. #define unlink(name) remove(name)
  242.  
  243. #if M_UNIX || M_XENIX
  244. int    __CDECL pclose(FILE *fp);
  245. FILE *    __CDECL popen(const char *command,const char *t);
  246. #endif
  247.  
  248. FILE *    __CLIB fdopen(int, const char *);
  249. int    __CLIB fcloseall(void);
  250. long    __CLIB filesize(const char *);
  251. int    __CLIB flushall(void);
  252. int    __CLIB getch(void);
  253. int    __CLIB getche(void);
  254. char *    __CLIB tempnam (const char *dir, const char *pfx);
  255. int     __CLIB _snprintf(char *,size_t,const char *,...);
  256. int    __CLIB _vsnprintf(char *,size_t,const char *,char *);
  257. #define _flushall flushall
  258. #define _fcloseall fcloseall
  259. #define _fdopen fdopen
  260. #define _tempnam tempnam
  261. #define _getche getche
  262. #define _getch getch
  263. #endif
  264.  
  265. #if __cplusplus
  266. }
  267. #endif
  268.  
  269. #endif /* __STDIO_H */
  270.  
  271.